package com.example.zhyq.repair

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.RepairBeanItem
import com.example.zhyq.R

class RepairAdapter : BaseQuickAdapter<RepairBeanItem, BaseViewHolder>(R.layout.item_repair) {
    override fun convert(helper: BaseViewHolder, item: RepairBeanItem) {
        helper.setText(R.id.repair_Num,item.orderNumber)
        helper.setText(R.id.repair_time,item.repairTime)
        helper.setText(R.id.repair_user,item.repairName)
        helper.setText(R.id.repair_phone,item.contactMethod)
        helper.setText(R.id.repair_location,item.repairLocation)
        helper.setText(R.id.repair_desc,item.faultDescription)

        val tv_status = helper.getView<TextView>(R.id.repair_status)
        tv_status.text = item.processingStatus

        if (item.processingStatus=="已完成"){
            tv_status.setTextColor(context.getColor(R.color.green))
            tv_status.setBackgroundResource(R.drawable.shape_status)
        }else if (item.processingStatus=="处理中") {
            tv_status.setTextColor(context.getColor(R.color.blue))
            tv_status.setBackgroundResource(R.drawable.shap_zhanyong)
        }else {
            tv_status.setTextColor(context.getColor(R.color.orange))
            tv_status.setBackgroundResource(R.drawable.shape_weihu)
        }
    }

}